package com.hejx.managecenter.common.dao;

import lombok.extern.slf4j.Slf4j;
import org.springframework.data.jpa.repository.support.SimpleJpaRepository;

import javax.persistence.EntityManager;
import javax.persistence.Query;
import java.io.Serializable;

/**
 * @program: managecenter_example
 * @description:
 * @author: hejx
 * @email: doubihah@foxmail.com
 * @create: 2018-06-26 22:19
 **/
@Slf4j
public class BaseDaoImpl <T,ID extends Serializable> extends SimpleJpaRepository<T,ID> implements BaseDao<T,ID>{

    private EntityManager entityManager;

    public BaseDaoImpl(Class<T> domainClass, EntityManager em) {
        super(domainClass, em);
        entityManager = em;
    }


    @Override
    public void findBySql(String sql) {
        Query nativeQuery = entityManager.createNativeQuery(sql);
        log.info("nativeQuery.getResultList().size():{}",nativeQuery.getResultList().size());
    }
}
